import service from "@/utils/request"

import LoginWork from "@/utils/LoginWork" 

// 入库明细查询
export interface QueryTheStorageDetailsInterface{
    total?: number,
    dtos: [],
    sendQtyTotal?:number
}

export interface dtos{
    slipType: string,
    recNo: string,
    recDate: string,
    sendDate: string,
    sendNo: string,
    purNo: string,
    vendorName: string,
    purLot: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: string,
    mtlUnit: string,
    kgQty: null,
    sendQty: number,
    financeRecMemo: null,
    sysUser: string,
    cfmFlag: string
}

export interface QueryTheStorageParms{
    mtlName:string,
    pageNum:number,
    pageSize:number,
    purLot:string,
    recDateEnd:string,
    recDateStart:string,
    recNo:string
}

export const QueryTheStorageDetails = (parms:QueryTheStorageParms) => {
    return service.put<any,QueryTheStorageDetailsInterface>('/pcFactorStockQuery/inStockDetailQuery',parms)
}

// 整单删除
export interface AllDtos{
    code: number
    data: string 
    message: string
}

export const BlockDeletion = (parms:string) => {
    return LoginWork.get<any,AllDtos>(`/pcFactorStockQuery/delateByRecNo?&recNo=${parms}`)
}

// 当前行删除
export interface CurrentLineParms{
    mtlColor:string,
    mtlName:string,
    purLot:string,
    purNo:string,
    recNo:string,
    sendNo:string,
    sendQty:string,
    slipType:string,
    vendorName:string,
    
}

export const CurrentLine = (parms:CurrentLineParms) => {
    return LoginWork.post<any,AllDtos>(`/pcFactorStockQuery/deleteRow?primaryId=${parms}`)
}

// 现暂收数量
export const QuantityCurrentlyAccepted = (parms:any,sendQty:number) => {
    return LoginWork.post<any,AllDtos>(`/pcFactorStockQuery/sendQtyUpdate?id=${parms}&sendQty=${sendQty}`)
}

// 厂商数据
export interface VendorQueryInterface{
    vendorNo: string,
    vendorName: string
}

export const VendorQuery = () => {
    return service.get<any,VendorQueryInterface[]>('/back/vendorQuery')
}

// 材料替代查询
export interface MaterialSubstitutionQueryParms{
    lotNo:string,
    mtlName:string,
    mtlName2:string,
    recNo:string
}

export interface MaterialSubstitutionQueryInterface{
    slipNo: string,
    lotNo: string,
    mtlNo: string,
    mtlName: string,
    mtlColor: string,
    mtlSpec: null,
    mtlUnit: string,
    qty: number,
    mtlNo2: string,
    mtlName2: string,
    mtlColor2: string,
    mtlSpec2: null,
    mtlUnit2: string,
    qty2: number,
    outType: string
}

export const MaterialSubstitutionQuery = (parms:MaterialSubstitutionQueryParms) => {
    return service.put<any,MaterialSubstitutionQueryInterface[]>('/pcFactorStockQuery/mtlSubQuery',parms)
}

// 确认修改
export interface confirmModificationParms{
    kgQtyUp:string,
    sendDateUp:string,
    sendNoUp:string,
    vendorNameUp:string,
    vendorNoUp:string,
    mtlColor:string,
    mtlName:string,
    purLot:string,
    purNo:string,
    recNo:string,
    sendNo:string,
    sendQty:string,
    slipType:string,
    vendorName:string,
}

export const confirmModification = (parms:confirmModificationParms,recNo:string) => {
    return LoginWork.put<any, AllDtos>(`/pcFactorStockQuery/otherDateUpdate/${recNo}`, parms);

}

// 替代用材料查询
export interface QueryWithMaterialsInsteadInterface{
    total?: number,
    dtos: []
}

export interface DtosQueryWithMaterials{
    mtlNo: string,
    mtlName: string,
    mtlColor: string,
    mtlSpec: null,
    mtlUnit: string,
    stkQty: number
}

export interface QueryWithMaterialsInsteadParms{
    lotNo:string,
    mtlName:string,
    mtlType:string,
    pageNum:number,
    pageSize:number
}

export const QueryWithMaterialsInstead = (parms:QueryWithMaterialsInsteadParms) => {
    return service.put<any,QueryWithMaterialsInsteadInterface>('/pcFactorStockQuery/subMtlQuery',parms)
}

//  材料替换处理
export interface MaterialReplacementTreatmentParms{
    lotNo:string,
    mtlColor:string,
    mtlColor2:string,
    mtlName:string,
    mtlName2:string,
    mtlNo:string,
    mtlNo2:string,
    mtlSpec:string,
    mtlSpec2:string,
    mtlUnit:string,
    mtlUnit2:string,
    outType:string,
    qty:number,
    qty2:number,
    slipNo:string,
    stkQty:number
}
  
export const MaterialReplacementTreatment = (parms:MaterialReplacementTreatmentParms) => {
    return LoginWork.put<any,any>('/pcFactorStockQuery/MtlSubProcess',parms)
}

// 材料替代新增
export interface MaterialSubstitutionAdditionParms{
    lotNo:string,
    mtlColor:string,
    mtlName:string,
    mtlNo:string,
    mtlSpec:string,
    mtlUnit:string,
    recNo:string,
    sendQty:string
    companyId?:string
}

export const MaterialSubstitutionAddition = (parms:MaterialSubstitutionAdditionParms) => {
    return LoginWork.put<any,AllDtos>('/pcFactorStockQuery/inStockMtlSub',parms)
}

// 海关编码查询
export const CustomsCodeQuery = () => {
    return service.get<any,any>(`/hgMtl/list?search=${''}`) 
}

export const CustomsCodeQuery1 = (parms:any) => {
    return service.get<any,any>(`/hgMtl/list?search=${parms}`) 
}

// 海关编码新增
export const CustomsCodeAddition = (parms:any) => {
    return LoginWork.post<any,any>('/hgMtl/add',parms) 
}

// 海关编码删除
export const CustomsCodeDeletion = (parms:any) => {
    return LoginWork.post<any,any>(`/hgMtl/delete?id=${parms}`) 
}